<?php
require_once 'base.php';

$tpl = new Template('t');
$tpl->setFile ( "main", "index.html" );
$tpl->setBlock ( "main", "block1", "block1s" );

$db = conn();

$types = fget("go", 0);
// ------- 设置左边点击后的样式 --------
$tpl->setvar("click{$types}", "class=\"active\"");
// ----- end ------ 
//----------------------显示list
if($types > 0)
	$where = " where types={$types}";
else
	$where = "";
$sql = "select count(*) from collect" . $where;
$rs=$db->query($sql, MYSQL_NUM);
$page_str = pageft($rs[0][0],20);
$sql = "select * from collect" . $where . " order by id desc {$page_str['limit']}";//不管是不是屏蔽的，都显示出来
$rs=$db->query($sql, MYSQL_ASSOC);
if(!empty($rs))
	foreach($rs as $v){
		$tpl->setvar(array("caption" => $v['caption'],
						"content" => $v['content'],
						"subtime" => $v['subtime'],
						"links" => $v['links']
				));
		$tpl->parse ( "block1s", "block1", true );
	}
$tpl->setvar("page_str", $page_str["str"]);

$db->close();
$tpl->p("main");
?>